 <?php /* @var $pager sfPropelPager */?>

<div class="category_title">
    <?php echo $gallery->getName() ?>
</div>

<?php if( has_any_role_id(array(MyConstants::ROLE_ADMIN, MyConstants::ROLE_MODERATOR)) ):?>
    <div id="" class="edit">
        <?php echo link_to(image_tag('pencil.png', 'style="border:0px;"'), 'gallery/edit?id=' . $gallery->getId()) ?>
    </div>
<?php endif; ?>

<?php if (!$pager->getNbResults()): ?>
    <?php echo __('No results') ?>.
<?php else: ?>

<!--
<div class="event_title">
    <?php echo link_to($gallery->getText(), 'gallery/display?id=' . $gallery->getId()) ?>
</div>
-->

<div class="display_gallery">
    <?php foreach ($pager->getResults() as $photo): ?>
    <div class="display_image">
        <?php echo link_to(
                    image_tag(
                        '/images/gallery/small/' . $photo->getUname()
                        , array(
                            'border' => '0'
                            , 'alt' => $photo->getUname()
                            , 'title' => $photo->getUname()
                        )
                    )
                    , 'http://darbuokis.lt/images/gallery/medium/' . $photo->getUname()
                    , array(
                        'class' => 'lightbox'
                    )
                )?>
        <?php /* echo $photo->getName() */ ?>
    </div>
    <?php endforeach; ?>
</div>

<div style="clear: both;"></div>

<?php endif; ?>

<?php if ($pager->haveToPaginate()): ?>
    <div class="paging">
        <div class="paging_link">
            <?php echo link_to(
                    '&laquo;'
                    , 'gallery/display?p='.$pager->getFirstPage()
                ) ?>
        </div>
        <div class="paging_link">
             <?php echo link_to(
                    '&lsaquo;'
                    , 'gallery/display?p='.$pager->getPreviousPage()
                ) ?>
        </div>
            <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
            <?php echo ($page == $pager->getPage()) ? '<div class="paging_current">' . $page . '</div>' : '<div class="paging_link">' . link_to($page, 'gallery/display?p='.$page) . '</div>' ?>
            <?php if ($page != $pager->getCurrentMaxLink()): ?>
            <?php endif; ?>
            <?php endforeach; ?>
        <div class="paging_link">
            <?php echo link_to(
                        '&rsaquo;'
                        , 'gallery/display?p='.$pager->getNextPage()
                    ) ?>
        </div>
        <div class="paging_link">
            <?php echo link_to(
                        '&raquo;'
                        , 'gallery/display?p='.$pager->getLastPage()
                    ) ?>
        </div>
    </div>
<?php endif ?>

<script type="text/javascript">
$(function() {
    $('a.lightbox').lightBox(); // Select all links with lightbox class
});
</script>